﻿using LiteBlog.Common.Entities;
using LiteBlog.Repositories.Common;
using LiteBlog.XmlLayer.Mocks.Constants;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using LiteBlog.Repositories;

namespace LiteBlog.Repositories.Tests
{
    [TestClass]
    public class CategoryRepositoryTests : StandardRepositoryTests<Category, CategoryRepository>
    {
        protected override void SetupLoad()
        {
            _getId = CategoryDataTestConstants.Id;
            _createId = CategoryDataTestConstants.CreateId;
            _updateId = CategoryDataTestConstants.UpdateId;
            _deleteId = CategoryDataTestConstants.DeleteId;
        }

        protected override string GetFileName()
        {
            return "Category.xml";
        }

        protected override Category GetObject(string id)
        {
            var category = new Category();
            category.CatID = id;
            category.Name = CategoryDataTestConstants.UpdateName;
            category.Count = CategoryDataTestConstants.UpdateCount;
            category.Order = CategoryDataTestConstants.UpdateOrder;
            return category;
        }

        protected override bool VerifyGet(Category item)
        {
            return _getId == item.CatID;
        }

        protected override bool VerifyUpdate(XElement elem)
        {
           var result = _updateElem.Attribute(Attr.Name)
                                    .Value
                                    .Equals(CategoryDataTestConstants.UpdateName);
            
            return result;
        }

        protected override bool VerifyCreate(XElement elem)
        {
            throw new NotImplementedException();
        }

        protected override bool VerifyDelete(XElement elem)
        {
            throw new NotImplementedException();
        }
    }
}
